using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Ras2ClassLib;

public partial class DispalyFlytjandaUppl : System.Web.UI.Page
{
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!this.IsPostBack)
		{
			FillList("");
		}
	}

	protected void FillList(String strOrderBy)
	{
		String strID = Request.QueryString["ID"];

		if (!String.IsNullOrEmpty(strID))
		{
			this.ViewState["ID"] = strID;
		}

		FlytjandiDoc doc = new FlytjandiDoc();
		Flytjandi flytjandi = doc.GetFlytjandi(Convert.ToInt32(strID));

		LagDoc DOC = new LagDoc();
		LagCollection lag = DOC.GetAllFlyt(Convert.ToInt32(strID));

		if (flytjandi != null)
		{
			m_lblName.Text = flytjandi.Name;
			m_lblDescription.Text = flytjandi.Description;

			if (flytjandi.URL.Length > 0)
			{
				m_hypURL.NavigateUrl = "http://" + flytjandi.URL;
			}
			else
			{
				m_hypURL.Text = "No website available";
			}
			if (flytjandi.Picture.Length > 0)
			{
				m_imgPicture.ImageUrl = flytjandi.Picture;
			}
			else
			{
				m_imgPicture.ImageUrl = "images/noimage.jpg";
				m_imgPicture.ToolTip = "No image in database";
			}
		}
		else
			{
				m_lblName.Text = "Fuck this";
			}

				m_GridViewFlyt.DataSource = lag;
				m_GridViewFlyt.DataBind();
			
			
		}

	protected void OnGridViewPageIndexChanging(object sender, GridViewPageEventArgs e)
	{
		m_GridViewFlyt.PageIndex = e.NewPageIndex;
		FillList(Convert.ToString(this.ViewState["SortColumn"]));
	}

	protected void OnGridViewSorting(object sender, GridViewSortEventArgs e)
	{
		FillList(e.SortExpression);
	}
}


